import request from '../utils/request'

export function userLogin (userInfo) {
  return request({
    url: '/login',
    method: 'post',
    data: userInfo
  })
}

export function userLogout () {
  return request({
    url: '/logout',
    method: 'get'
  })
}

// export function getUserMenu () {
//   return request({
//     url: '/user/menu',
//     method: 'get'
//   })
// }

export function userRegister (user) {
  return request({
    url: '/register',
    method: 'post',
    data: user
  })
}

export function userInfo (userId) {
  if (userId) {
    return request({
      url: `/user/info/${userId}`,
      method: 'get'
    })
  }
  return request({
    url: '/user/info/',
    method: 'get'
  })
}

export function userList (query) {
  return request({
    url: '/user/list',
    method: 'get',
    params: query
  })
}

export function userUpdate (user) {
  return request({
    url: '/user/update',
    method: 'put',
    data: user
  })
}

export function userDelete (user) {
  return request({
    url: '/user/delete',
    method: 'delete',
    data: user
  })
}

export function userStatusEnable (user) {
  return request({
    url: '/user/enable',
    method: 'post',
    data: user
  })
}
export function userInsert (User) {
  return request({
    url: '/user',
    method: 'post',
    data: User
  })
}

export function getUserMenu () {
  return request({
    url: '/permission/menu',
    method: 'get'
  })
}

/**
 * 重置用户密码
 * @param data
 */
export function userResetPassword (data) {
  return request({
    url: '/reset/password',
    method: 'post',
    data: data
  })
}

/**
 * 发送验证码
 */
export function sendCheckCode (params) {
  return request({
    url: '/send/code',
    method: 'get',
    params: params
  })
}
